CUBE CONNECT Edition Help

Creating a new CUBE Network within a CUBE Database with the CubeDatabase class

The createNetwork() method can be used to create a new highway network within the CUBE database, created in Creating a new CUBE Database with the CubeDatabase class.

The createNetwork() method requires the following arguments:

  • name = string, name of the new network dataset (no-default).
  • nodeAttributes = vector of node attributes, this could be a Python list or cp.FieldVector() (no-default).

Each element of the list needs to be defined with a cp.Field() method, requiring name and type of the attribute as arguments. Types can be specified with their numeric code (e.g., 0 for Integer type), or with the enumerator (e.g, cp.FieldType_Integer), nevertheless, we would recommend not using numbers for the enumerated types as these numbers may change in the future. Therefore, as an example, the nodeAttributes vector will have a structure of the type:

nodeAttributes = [cp.Field("attr_name1", cp.FieldType_Integer),	
																										cp.Field("attr_name2", cp.FieldType_String)]

  • linkAttributes = vector of link attributes, this could be a Python list or cp.FieldVector() (no-default). The same approach described above for node attributes should be used.
  • maxZoneNumber = integer defining the maximum zone number (no-default).
  • startingNodeNumber = integer defining the starting node number (no-default).
  • spatialReferenceId = integer defining the spatial reference identifer to be set (no-default).
  • distanceAttributeName = string defining the name of the attribute to be used for distance, if any (default is none).
  • distanceUnitExponent = power of 10 to associate with the distance value (default is 0).
  • rightHandDrive = Boolean defining whether the network uses right hand drive (default is True).

An example of the definition of the new network is provided below:

nodeAttributes = [cp.Field("attr_name1", cp.FieldType_Integer)]  
# example with int for the node attributes
linkAttributes = [cp.Field("attr_name1", cp.FieldType_Integer), cp.Field("attr_name2", cp.FieldType_String)]  
# example with int and str for the link attributes
max_zone_nr = 1000
starting_node_nr = 1001
srid = 4326  # EPSG:4326 - WGS 84 
db.createNetwork("new_network", nodeAttributes, linkAttributes, max_zone_nr, starting_node_nr, srid)